package edu.stanford.bmir.protege.web.client.rpc.stkosutil;

import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;

import edu.stanford.bmir.protege.web.client.rpc.data.EntityData;
import edu.stanford.bmir.protege.web.client.rpc.data.PaginationData;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.common.SearchCondition;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.common.TripleData;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.common.UtilEntityType;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.cutter.CancelCutterResult;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.cutter.CuttingOptions;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.cutter.CuttingResult;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.cutter.RemoveEntityResult;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.cutter.actions.CancelCutterAction;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.enricher.CancelEnricherResult;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.enricher.CandidateEntity;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.enricher.EnrichmentOptions;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.enricher.EnrichmentResult;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.enricher.OriginEntity;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.enricher.SourceThesaurus;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.enricher.actions.CancelEnricherAction;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.enricher.actions.CreateCandidateClassesAction;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.enricher.actions.CreateCandidateClassesResult;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.enricher.actions.CreateTriplesAction;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.enricher.actions.CreateTriplesResult;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.mapper.CancelMapperResult;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.mapper.MappingOptions;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.mapper.MappingResult;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.mapper.actions.CancelMapperAction;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.merger.CancelMergerResult;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.merger.MergenceOptions;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.merger.MergenceResult;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.merger.actions.CancelMergerAction;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.merger.actions.MergeEntityAction;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.merger.actions.MergeEntityResult;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.statistics.StatisticsResult;
import edu.stanford.bmir.protege.web.shared.project.ProjectId;

public class StkosUtilServiceManager {
	private static StkosUtilServiceAsync proxy;
	static StkosUtilServiceManager instance;

	private StkosUtilServiceManager() {
		proxy = (StkosUtilServiceAsync) GWT.create(StkosUtilService.class);
	}

	public static StkosUtilServiceManager getInstance() {
		if (instance == null) {
			instance = new StkosUtilServiceManager();
		}
		return instance;
	}

	public StkosUtilServiceAsync getProxy() {
		return StkosUtilServiceManager.proxy;
	}

	public void addAnnotaionValue(ProjectId projectId,
			java.lang.String entityName, java.lang.String annotaionName,
			java.lang.String annotaionValue,
			AsyncCallback<java.lang.String> callback) {
		proxy.addAnnotaionValue(projectId.getId(), entityName, annotaionName,
				annotaionValue, callback);
	}

	public void updateAnnotaionValue(ProjectId projectId, String entityName,
			UtilEntityType entityType, String annotaionName,
			String annotaionValue, AsyncCallback<Void> callback) {
		proxy.updateAnnotaionValue(projectId.getId(), entityName, entityType,
				annotaionName, annotaionValue, callback);
	}

	public void removeAnnotationValue(String projectName, String entityName,
			UtilEntityType entityType, String annotaionName,
			String annotaionValuePattern, AsyncCallback<Integer> callback) {
		proxy.removeAnnotationValue(projectName, entityName, entityType,
				annotaionName, annotaionValuePattern, callback);
	}

	public void mapOntologies(String project1Name, String project2Name,
			MappingOptions options, AsyncCallback<MappingResult> callback) {
		proxy.mapOntologies(project1Name, project2Name, options, callback);
	}

	public void search(String projectName, SearchCondition searchCondition,
			int start, int limit, String sort, String dir,
			AsyncCallback<PaginationData<EntityData>> callback) {
		proxy.search(projectName, searchCondition, start, limit, sort, dir,
				callback);
	}

	public void search(String projectName, SearchCondition searchCondition,
			AsyncCallback<List<EntityData>> callback) {
		proxy.search(projectName, searchCondition, callback);
	}

	public void cutOntology(String projectName, CuttingOptions options,
			AsyncCallback<CuttingResult> callback) {
		// TODO Auto-generated method stub
		proxy.cutOntology(projectName, options, callback);
	}

	public void fetchCandidateEntities(String projectName,
			OriginEntity originEntity, EnrichmentOptions options,
			AsyncCallback<List<CandidateEntity>> callback) {
		proxy.fetchCandidateEntities(projectName, originEntity, options,
				callback);
	}

	public void fetchCandidateTriples(String projectName,
			OriginEntity originEntity, EnrichmentOptions options,
			AsyncCallback<List<TripleData>> callback) {
		proxy.fetchCandidateTriples(projectName, originEntity, options,
				callback);
	}

	public void enrichOntology(String projectName, EnrichmentOptions options,
			AsyncCallback<EnrichmentResult> callback) {
		proxy.enrichOntology(projectName, options, callback);
	}

	public void fetchSourceThesaurusList(
			AsyncCallback<List<SourceThesaurus>> callback) {
		proxy.fetchSourceThesaurusList(callback);
	}

	public void createCandidateClasses(String projectName,
			CreateCandidateClassesAction action,
			AsyncCallback<CreateCandidateClassesResult> callback) {
		proxy.createCandidateClasses(projectName, action, callback);
	}

	public void mergeOntology(String projectName, MergenceOptions options,
			AsyncCallback<MergenceResult> callback) {
		proxy.mergeOntology(projectName, options, callback);
	}

	public void mergeEntity(String projectName, MergeEntityAction action,
			AsyncCallback<MergeEntityResult> callback) {
		proxy.mergeEntity(projectName, action, callback);
	}

	public void removeCutEntities(String projectName,
			AsyncCallback<RemoveEntityResult> callback) {
		proxy.removeCutEntities(projectName, callback);
	}

	public void createTriples(String projectName, CreateTriplesAction action,
			AsyncCallback<CreateTriplesResult> callback) {
		proxy.createTriples(projectName, action, callback);
	}

	public void countEntities(String projectName,
			AsyncCallback<StatisticsResult> callback) {
		proxy.countEntities(projectName, callback);
	}

	/**
	 * cancel merger
	 * 
	 * @param projectName
	 *            The operation project`s name.
	 * @param action
	 *            The cancel action.
	 * @param callback
	 *            The callback function.
	 */
	public void cancelMerger(String projectName, CancelMergerAction action,
			AsyncCallback<CancelMergerResult> callback) {
		proxy.cancelMerger(projectName,action, callback);
	}
	
	/**
	 * cancel enricher
	 * 
	 * @param projectName
	 *            The operation project`s name.
	 * @param action
	 *            The cancel action.
	 * @param callback
	 *            The callback function.
	 */
	public void cancelEnricher(String projectName, CancelEnricherAction action,
			AsyncCallback<CancelEnricherResult> callback) {
		proxy.cancelEnricher(projectName,action, callback);
	}
	/**
	 * cancel cutter
	 * 
	 * @param projectName
	 *            The operation project`s name.
	 * @param action
	 *            The cancel action.
	 * @param callback
	 *            The callback function.
	 */
	public void cancelCutter(String projectName, CancelCutterAction action,
			AsyncCallback<CancelCutterResult> callback) {
		proxy.cancelCutter(projectName,action, callback);
	}
	/**
	 * cancel mapper
	 * 
	 * @param projectName
	 *            The operation project`s name.
	 * @param action
	 *            The cancel action.
	 * @param callback
	 *            The callback function.
	 */
	public void cancelMapper(String projectName, CancelMapperAction action,
			AsyncCallback<CancelMapperResult> callback) {
		proxy.cancelMapper(projectName,action, callback);
	}
}
